﻿using System;
using System.Web.Security;
using System.Web.UI;
using AdventureWorks.Application.Presenters;
using AdventureWorks.Application.Views;
using AspNetExtensions.Pages;

public partial class Login : BasePage<LoginPresenter, ILoginView>, ILoginView {

  #region ILoginView Members

  public String Password {
    get {
      return PasswordInput.Text;
    }
  }
  public bool RememberUser {
    get {
      return RememberMeInput.Checked;
    }
    set {
      RememberMeInput.Checked = value;
    }
  }
  public string Username {
    get {
      return UsernameInput.Text;
    }
    set {
      UsernameInput.Text = value;
    }
  }
  public string ErrorMessage {
    set {
      CustomValidator1.IsValid = false;
      CustomValidator1.ErrorMessage = value;
    }
  }
  public void RedirectFromLoginPage() {
    FormsAuthentication.RedirectFromLoginPage(this.Username, this.RememberUser);
  }
  #endregion
  protected void SignInButton_Click(object sender, EventArgs e) {
    if (Page.IsValid)
      presenter.OnLogin();
  }
}